﻿using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using System.Diagnostics;

namespace Project.Core.Config.Config.Cache {
    public static class BuilderCacheExtensions {
        public static void AddCacheBuilder(this WebApplicationBuilder builder) {
            Debug.WriteLine("配置Cache");

            // 添加Redis缓存服务
            // 获取实体类
            //var settings = Configuration.GetSection("RedisConfig").Get<RedisConfigInfo>();
            //// 设置配置参数
            //var options = new RedisCacheOptions {
            //    InstanceName = settings.instanceName,
            //    Configuration = settings.connection
            //};
            //// 实例化帮助类
            //var helper = new RedisCacheHelper(options, settings.database);
            //services.AddSingleton<ICacheHelper>(helper);
            // 启用本地缓存
            builder.Services.AddMemoryCache();
            //添加Memory缓存服务
            builder.Services.AddScoped<ICacheHelper, MemoryCacheHelper>();
        }
    }
}
